{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\Jungyeon PARK\Dropbox\Discrimination Project_for me\FEVS_FACTOR SCORES_ORG FAIRNESS\2013_FEVS_Log.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}10 Oct 2021, 14:39:20

{com}. do "C:\Users\JUNGYE~1\AppData\Local\Temp\STD333c_000000.tmp"
{txt}
{com}. import delimited "C:\Users\Jungyeon PARK\Dropbox\DISCRIMINATION PROJECT (U.S. FEDERAL AGENCIES)\FEVS\FEVS_2010-2019\FEVS2013_PRDF.csv
{res}{text}(99 vars, 376,577 obs)

{com}. 
. svyset [pweight=postwt]

      {txt}pweight:{col 16}{res}postwt
          {txt}VCE:{col 16}{res}linearized
  {txt}Single unit:{col 16}{res}missing
     {txt}Strata 1:{col 16}<one>
         SU 1:{col 16}<observations>
        FPC 1:{col 16}<zero>
{p2colreset}{...}

{com}. 
. drop if q17=="X"
{txt}(16,155 observations deleted)

{com}. 
. drop if q17==""
{txt}(2,733 observations deleted)

{com}. 
. drop if q37=="X"
{txt}(16,043 observations deleted)

{com}. 
. drop if q37==""
{txt}(8,728 observations deleted)

{com}. 
. drop if q38=="X"
{txt}(15,349 observations deleted)

{com}. 
. drop if q38==""
{txt}(2,886 observations deleted)

{com}. 
. destring q17, replace
{txt}q17: all characters numeric; {res}replaced {txt}as {res}byte
{txt}
{com}. 
. destring q37, replace
{txt}q37: all characters numeric; {res}replaced {txt}as {res}byte
{txt}
{com}. 
. destring q38, replace
{txt}q38: all characters numeric; {res}replaced {txt}as {res}byte
{txt}
{com}. 
. svy linearized : gsem (FAIRNESS -> q17, family(ordinal) link(logit)) (FAIRNESS -> q37, family(ordinal) link(logit)) (FAIRNESS -> q38, family(ordinal) link(logit)), covstruct(_lexogenous, diagonal) latent(FAIRNESS) nocapslatent
{txt}(running gsem on estimation sample)
{res}
{txt}Survey: Generalized structural equation model

{col 1}Number of strata{col 20}= {res}        1{txt}{col 49}Number of obs{col 67}= {res}   314,683
{txt}{col 1}Number of PSUs{col 20}= {res}  314,683{txt}{col 49}Population size{col 67}={res}  1,496,583
{txt}{col 49}Design df{col 67}= {res}   314,682

{txt}Response{col 16}: {res}q17
{txt}Family{col 16}: {res}ordinal
{txt}Link{col 16}: {res}logit

{txt}Response{col 16}: {res}q37
{txt}Family{col 16}: {res}ordinal
{txt}Link{col 16}: {res}logit

{txt}Response{col 16}: {res}q38
{txt}Family{col 16}: {res}ordinal
{txt}Link{col 16}: {res}logit

{p 0 7}{space 1}{text:( 1)}{space 1} [q17]FAIRNESS = 1{p_end}
{txt}{hline 14}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{col 15}{c |}{col 27}  Linearized
{col 15}{c |}      Coef.{col 27}   Std. Err.{col 39}      t{col 47}   P>|t|{col 55}     [95% Con{col 68}f. Interval]
{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}q17           {txt}{c |}
{space 5}FAIRNESS {c |}{col 15}{res}{space 2}        1{col 27}{txt}  (constrained)
{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}q37           {txt}{c |}
{space 5}FAIRNESS {c |}{col 15}{res}{space 2} 1.788509{col 27}{space 2} .0164977{col 38}{space 1}  108.41{col 47}{space 3}0.000{col 55}{space 4} 1.756174{col 68}{space 3} 1.820844
{txt}{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}q38           {txt}{c |}
{space 5}FAIRNESS {c |}{col 15}{res}{space 2} 2.143423{col 27}{space 2} .0270274{col 38}{space 1}   79.31{col 47}{space 3}0.000{col 55}{space 4}  2.09045{col 68}{space 3} 2.196396
{txt}{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}/q17          {txt}{c |}
{space 9}cut1 {c |}{col 15}{res}{space 2}-3.401086{col 27}{space 2} .0141814{col 55}{space 4}-3.428881{col 68}{space 3}-3.373291
{txt}{space 9}cut2 {c |}{col 15}{res}{space 2}-2.243316{col 27}{space 2} .0109747{col 55}{space 4}-2.264826{col 68}{space 3}-2.221806
{txt}{space 9}cut3 {c |}{col 15}{res}{space 2} -.787675{col 27}{space 2} .0086299{col 55}{space 4}-.8045894{col 68}{space 3}-.7707606
{txt}{space 9}cut4 {c |}{col 15}{res}{space 2} 1.808385{col 27}{space 2} .0104463{col 55}{space 4}  1.78791{col 68}{space 3} 1.828859
{txt}{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}/q37          {txt}{c |}
{space 9}cut1 {c |}{col 15}{res}{space 2}-4.457045{col 27}{space 2} .0311824{col 55}{space 4}-4.518161{col 68}{space 3}-4.395928
{txt}{space 9}cut2 {c |}{col 15}{res}{space 2}-2.699479{col 27}{space 2} .0216089{col 55}{space 4}-2.741832{col 68}{space 3}-2.657126
{txt}{space 9}cut3 {c |}{col 15}{res}{space 2} -.328967{col 27}{space 2} .0128129{col 55}{space 4}  -.35408{col 68}{space 3} -.303854
{txt}{space 9}cut4 {c |}{col 15}{res}{space 2} 3.769722{col 27}{space 2} .0271505{col 55}{space 4} 3.716508{col 68}{space 3} 3.822937
{txt}{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}/q38          {txt}{c |}
{space 9}cut1 {c |}{col 15}{res}{space 2}-6.511134{col 27}{space 2} .0613656{col 55}{space 4}-6.631409{col 68}{space 3} -6.39086
{txt}{space 9}cut2 {c |}{col 15}{res}{space 2}-4.806342{col 27}{space 2} .0465868{col 55}{space 4}-4.897651{col 68}{space 3}-4.715033
{txt}{space 9}cut3 {c |}{col 15}{res}{space 2}-1.783415{col 27}{space 2} .0222981{col 55}{space 4}-1.827118{col 68}{space 3}-1.739711
{txt}{space 9}cut4 {c |}{col 15}{res}{space 2} 3.301536{col 27}{space 2} .0333365{col 55}{space 4} 3.236198{col 68}{space 3} 3.366875
{txt}{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 1}var(FAIRNESS){c |}{col 15}{res}{space 2} 3.912035{col 27}{space 2} .0441384{col 55}{space 4} 3.826474{col 68}{space 3} 3.999508
{txt}{hline 14}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}

{com}. 
. predict fairnessgsem, latent(FAIRNESS)
{txt}(option {bf:ebmeans} assumed)
{res}{txt}(using 7 quadrature points)

{com}. 
. egen average_fairnessgsem = mean (fairnessgsem), by (agency)
{txt}
{com}. 
. egen sub_average_fairnessgsem = mean (fairnessgsem), by (plevel1)
{txt}
{com}. 
. egen sub2_average_fairnessgsem = mean (fairnessgsem), by (plevel2)
{txt}
{com}. 
. svy linearized : sem (FAIRNESSSEM -> q38 q37 q17), covstruct(_lexogenous, diagonal) standardized latent(FAIRNESSSEM) nocapslatent
{txt}(running sem on estimation sample)
{res}
{txt}{col 1}Survey: Structural equation model{col 49}Number of obs{col 67}= {res}   314,683
{txt}{col 1}Number of strata{col 22}= {res}        1{txt}{col 49}Population size{col 67}={res}  1,496,583
{txt}{col 1}Number of PSUs{col 22}= {res}  314,683{txt}{col 49}Design df{col 67}= {res}   314,682

{p 0 7}{space 1}{text:( 1)}{space 1} [q38]FAIRNESSSEM = 1{p_end}
{txt}{hline 16}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{col 17}{c |}{col 29}  Linearized
{col 1}   Standardized{col 17}{c |}      Coef.{col 29}   Std. Err.{col 41}      t{col 49}   P>|t|{col 57}     [95% Con{col 70}f. Interval]
{hline 16}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{col 1}{res}Measurement    {col 17}{txt}{c |}
{space 2}{col 3}q38          {col 17}{c |}
{space 4}FAIRNESSSEM {c |}{col 17}{res}{space 2} .8587905{col 29}{space 2} .0016344{col 40}{space 1}  525.46{col 49}{space 3}0.000{col 57}{space 4} .8555872{col 70}{space 3} .8619938
{txt}{space 10}_cons {c |}{col 17}{res}{space 2} 3.266975{col 29}{space 2} .0079105{col 40}{space 1}  412.99{col 49}{space 3}0.000{col 57}{space 4} 3.251471{col 70}{space 3}  3.28248
{space 2}{txt}{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 2}{col 3}q37          {col 17}{c |}
{space 4}FAIRNESSSEM {c |}{col 17}{res}{space 2} .8447791{col 29}{space 2} .0016491{col 40}{space 1}  512.27{col 49}{space 3}0.000{col 57}{space 4} .8415469{col 70}{space 3} .8480113
{txt}{space 10}_cons {c |}{col 17}{res}{space 2} 2.679704{col 29}{space 2}  .005483{col 40}{space 1}  488.73{col 49}{space 3}0.000{col 57}{space 4} 2.668957{col 70}{space 3}  2.69045
{space 2}{txt}{hline 14}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 2}{col 3}q17          {col 17}{c |}
{space 4}FAIRNESSSEM {c |}{col 17}{res}{space 2} .6983317{col 29}{space 2} .0020131{col 40}{space 1}  346.89{col 49}{space 3}0.000{col 57}{space 4} .6943861{col 70}{space 3} .7022774
{txt}{space 10}_cons {c |}{col 17}{res}{space 2} 2.931489{col 29}{space 2} .0064692{col 40}{space 1}  453.14{col 49}{space 3}0.000{col 57}{space 4}  2.91881{col 70}{space 3} 2.944169
{txt}{hline 16}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 6}var(e.q38){c |}{col 17}{res}{space 2} .2624789{col 29}{space 2} .0028072{col 57}{space 4} .2570342{col 70}{space 3} .2680389
{txt}{space 6}var(e.q37){c |}{col 17}{res}{space 2} .2863483{col 29}{space 2} .0027862{col 57}{space 4}  .280939{col 70}{space 3} .2918616
{txt}{space 6}var(e.q17){c |}{col 17}{res}{space 2} .5123328{col 29}{space 2} .0028116{col 57}{space 4} .5068516{col 70}{space 3} .5178733
{txt}var(FAIRNESSSEM){c |}{col 17}{res}{space 2}        1{col 29}{space 2}        .{col 57}{space 4}        .{col 70}{space 3}        .
{txt}{hline 16}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}

{com}. 
. estat gof, stats(all)
{res}
{txt}{hline 21}{c TT}{hline 54}
{lalign 21:Fit statistic}{c |}      Value   Description
{hline 21}{c +}{hline 54}
{lalign 21:Size of residuals}{c |}
{ralign 20:SRMR} {c |} {res}{ralign 10:     0.000}{txt}   Standardized root mean squared residual
{ralign 20:CD} {c |} {res}{ralign 10:     0.862}{txt}   Coefficient of determination
{hline 21}{c BT}{hline 54}
{p 0 2 2 75}Note: model was fit with{txt} svy: prefix; only stats(residuals) valid.{p_end}

{com}. 
. predict fairnesssem, latent(FAIRNESSSEM)
{res}{txt}
{com}. 
. egen average_fairnesssem = mean (fairnesssem), by (agency)
{txt}
{com}. 
. egen sub_average_fairnesssem = mean (fairnesssem), by (plevel1)
{txt}
{com}. 
. egen sub2_average_fairnesssem = mean (fairnesssem), by (plevel2)
{txt}
{com}. 
. correlate fairnessgsem fairnesssem
{txt}(obs=314,683)

             {c |} fai~gsem fai~ssem
{hline 13}{c +}{hline 18}
fairnessgsem {c |}{res}   1.0000
 {txt}fairnesssem {c |}{res}   0.9811   1.0000

{txt}
{com}. 
{txt}end of do-file

{com}. save "C:\Users\Jungyeon PARK\Dropbox\Discrimination Project_for me\FEVS_FACTOR SCORES_ORG FAIRNESS\2013_FEVS_DATA.dta"
{txt}file C:\Users\Jungyeon PARK\Dropbox\Discrimination Project_for me\FEVS_FACTOR SCORES_ORG FAIRNESS\2013_FEVS_DATA.dta saved

{com}. exit, clear
